//账号密码对应登录按钮
function input(){
    if($(".zhanghao").val() && $(".mima").val() && $("#queren").val()){
        $(".anniu").attr("style","background: #f54a35;color: #fff");
    }else{
        $(".anniu").attr("style","");
    }
}
window.onload = function(){
    input()
} 
$(".zhanghao")[0].oninput = function(){
    input()
}
$(".mima")[0].oninput = function(){
    input()
}
$("#queren")[0].oninput = function(){
    input()
}
$(".anniu").click(function(){
    let zhang = $(".zhanghao").val();
    let mima = $(".mima").val();
    let mimayanzheng = $("#queren").val();
    let zhengze = /[A-z0-9]/
    if(!zhang || !mima){
        alert("请输入账号或密码");
        return;
    }
    //正则验证
    if(!zhengze.test(zhang) || !zhengze.test(mima) || !zhengze.test(mimayanzheng)){
        alert("请输入正确规则的账号或密码");
        return
    }
    if(mima !== mimayanzheng){
        alert("两次密码输入不一致");
        return;
    }
    let http = new XMLHttpRequest();
    http.open("get",`http://127.0.0.1:8088/n?name=${zhang}&word=${mima}`);
    http.send();
    http.onreadystatechange = function(){
        if(http.readyState === 4){
            if(http.responseText === "cuo"){
                alert("已有账户注册，注册失败")
            }
            if(http.responseText === "dui"){
                alert("注册成功，去登录吧")
                location.href = "http://127.0.0.1/zkhl/qian/denglu.html"
            }
        }
    }
})